package com.sumainfor.pc.gmio.controller.housekeeper;

import com.sumainfor.common.entity.ParentDeptVo;
import com.sumainfor.common.entity.SysUserVo;
import com.sumainfor.common.util.ContextUtils;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.feign.Zfeign.ZzuulFeign;
import com.sumainfor.pc.gmio.service.HoKeepTenantService;
import com.sumainfor.pc.gmio.service.HoTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 *服务管家租客管理
 */
@RestController
@RequestMapping("/housekeeper/HoKeepTenant")
public class HoKeepTenantController implements Serializable {
    @Autowired
    private HoKeepTenantService hoKeepTenantService;
    @Autowired
    private ZzuulFeign zzuulFeign;
    /**
     * 查询管家评价的列表
     * @param params
     * @param pager
     * @return
     */
    @PostMapping("/getHoKeepTenantList")
    public JsonResult getHoKeepTenantList(@RequestBody Map<String,Object> params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
        pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
        PageUtils pageUtils = new PageUtils();
        Integer cout=hoKeepTenantService.getHoKeepTenantListCount(params);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=hoKeepTenantService.getHoKeepTenantList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     *
     * 查询服务中心下的全部角色列表，租赁顾问查询转单的伙伴
     */
    @GetMapping("/getWoSaleIdList")
    public JsonResult getWoSaleIdList(@RequestParam Map<String,Object> params){
        //获取当前登录人的服务中心编号
        SysUserVo userVo = ContextUtils.getSysUser();
        ParentDeptVo vo = null;
        for (int i = 0; i < userVo.getLength(); i++) {
            ParentDeptVo vo1 = userVo.getParentDeptVo();
            if (vo1.getType().equals(3)) {
                vo = vo1;
                break;
            }
        }
        if (vo!=null){
            params.put("area_id",vo.getDeptId());//当前登录人的服务中心编号
            System.out.println("area_id:"+vo.getDeptId());
        }
        return zzuulFeign.getWoSaleIdList(params);
    }
}
